﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace MPMovieCatalog.Settings.Sections
{
    public sealed class ConnectionConfigurationSection : ConfigurationSection
    {
        private string m_host;

        private string m_port;

        public ConnectionConfigurationSection() { }

        [ConfigurationProperty("propertyElements")]
        public PropertyElementCollection PropertyElements
        {
            get
            {
                return (PropertyElementCollection)base["propertyElements"] ?? new PropertyElementCollection();
            }
        }

        //        [ConfigurationProperty("host")]
        //        public SettingConfigurationElement Host
        public string Host
        {
            get
            {
                //                SettingConfigurationElement host = (SettingConfigurationElement)base["host"];
                //                return host;
                return m_host;
            }

            set
            {
                //                base["host"] = value;
                m_host = value;
            }
        }

        //        [ConfigurationProperty("port")]
        //        public SettingConfigurationElement Port
        public string Port
        {
            get
            {
                //                SettingConfigurationElement port = (SettingConfigurationElement)base["port"];
                //                return port;
                return m_port;
            }
            set
            {
                //                base["port"] = value;
                m_port = value;
            }
        }

        /*        protected override bool SerializeToXmlElement(System.Xml.XmlWriter writer, string elementName)
                {
                    writer.WriteStartElement(elementName);
                    writer.WriteStartElement("property");
                    writer.WriteAttributeString("name", "host");
                    writer.WriteAttributeString("value", this.Host);
                    writer.WriteEndElement();

                    writer.WriteStartElement("property");
                    writer.WriteAttributeString("name", "port");
                    writer.WriteAttributeString("value", this.Port);
                    writer.WriteEndElement();
                    writer.WriteEndElement();

                    return true;
                }*/

    }
}
